package com.orange.score.model.match;

import android.database.Cursor;
import android.graphics.Color;
import android.util.Log;
import com.orange.common.util.StringUtil;
import com.orange.score.model.config.ConfigManager;
import com.orange.score.utils.DataUtils;
import java.util.Date;

public class Match
  implements Comparable<Match>
{
  static final int[] LEAGUE_COLOR;
  private static final int MATCH_DATE_LENGTH = 14;
  static int MIN_SCORE_UPDATE_INTERVAL = 0;
  private static final String TAG = "Match";
  private static final int UNKNOWN_COLOR = -1;
  String awayCantoneseName;
  String awayTeamFirstHalfScore;
  String awayTeamImageUrl;
  public String awayTeamName;
  String awayTeamRank;
  public String awayTeamRed;
  public String awayTeamScore;
  public String awayTeamYellow;
  String crownChupan;
  String crownChupanString = null;
  String date;
  Date dateOfStartDate;
  String hasLineup;
  String homeCantoneseName;
  String homeTeamFirstHalfScore;
  String homeTeamImageUrl;
  public String homeTeamName;
  String homeTeamRank;
  public String homeTeamRed;
  public String homeTeamScore;
  public String homeTeamYellow;
  boolean isFollow;
  public long latestScoreUpdateTime;
  int leagueColor = -1;
  String leagueId;
  String leagueName;
  public String matchId;
  String matchTime;
  String startDate;
  int status;

  static
  {
    int[] arrayOfInt = new int[5];
    arrayOfInt[0] = Color.argb(255, 81, 142, 210);
    arrayOfInt[1] = Color.argb(255, 232, 129, 26);
    arrayOfInt[2] = Color.argb(255, 148, 151, 32);
    arrayOfInt[3] = Color.argb(255, 141, 109, 214);
    arrayOfInt[4] = Color.argb(255, 83, 172, 152);
    LEAGUE_COLOR = arrayOfInt;
    MIN_SCORE_UPDATE_INTERVAL = 10000;
  }

  public Match()
  {
    this.isFollow = false;
    this.latestScoreUpdateTime = 0L;
  }

  private boolean hasCard(String paramString)
  {
    int i;
    if ((paramString != null) && (paramString.length() > 0) && (Integer.parseInt(paramString) > 0))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  private int safeGetInt(String paramString)
  {
    int i;
    if ((paramString == null) || (paramString.length() == 0))
      i = 0;
    while (true)
    {
      return i;
      i = Integer.parseInt(paramString);
    }
  }

  public int compareTo(Match paramMatch)
  {
    int i;
    if (this.status == paramMatch.status)
      i = this.date.compareTo(paramMatch.date);
    while (true)
    {
      while (true)
      {
        boolean bool1;
        boolean bool2;
        while (true)
        {
          return i;
          bool1 = isFinish();
          bool2 = paramMatch.isFinish();
          if ((!(bool1)) || (bool2))
            break;
          i = 1;
        }
        if ((bool1) || (!(bool2)))
          break;
        i = -1;
      }
      i = this.date.compareTo(paramMatch.date);
    }
  }

  public boolean equals(Object paramObject)
  {
    int i;
    if (!(paramObject instanceof Match))
      i = 0;
    while (true)
    {
      while (true)
      {
        return i;
        Match localMatch = (Match)paramObject;
        if ((!(this.matchId.equals(this.matchId))) || (!(this.leagueName.equals(localMatch.leagueName))) || (!(this.homeTeamName.equals(localMatch.homeTeamName))) || (!(this.awayTeamName.equals(localMatch.awayTeamName))))
          break;
        i = 1;
      }
      i = 0;
    }
  }

  public void fromCursor(Cursor paramCursor)
  {
    int i15;
    int i = 0 + 1;
    this.matchId = paramCursor.getString(0);
    int j = i + 1;
    this.leagueId = paramCursor.getString(i);
    int k = j + 1;
    this.status = paramCursor.getInt(j);
    int l = k + 1;
    this.date = paramCursor.getString(k);
    int i1 = l + 1;
    this.startDate = paramCursor.getString(l);
    int i2 = i1 + 1;
    this.homeTeamName = paramCursor.getString(i1);
    int i3 = i2 + 1;
    this.awayTeamName = paramCursor.getString(i2);
    int i4 = i3 + 1;
    this.homeTeamScore = paramCursor.getString(i3);
    int i5 = i4 + 1;
    this.awayTeamScore = paramCursor.getString(i4);
    int i6 = i5 + 1;
    this.homeTeamFirstHalfScore = paramCursor.getString(i5);
    int i7 = i6 + 1;
    this.awayTeamFirstHalfScore = paramCursor.getString(i6);
    int i8 = i7 + 1;
    this.homeTeamRed = paramCursor.getString(i7);
    int i9 = i8 + 1;
    this.awayTeamRed = paramCursor.getString(i8);
    int i10 = i9 + 1;
    this.homeTeamYellow = paramCursor.getString(i9);
    int i11 = i10 + 1;
    this.awayTeamYellow = paramCursor.getString(i10);
    int i12 = i11 + 1;
    this.crownChupan = paramCursor.getString(i11);
    int i13 = i12 + 1;
    this.leagueName = paramCursor.getString(i12);
    int i14 = i13 + 1;
    if (paramCursor.getInt(i13) == 1)
      i15 = 1;
    while (true)
    {
      this.isFollow = i15;
      int i16 = i14 + 1;
      this.homeCantoneseName = paramCursor.getString(i14);
      int i17 = i16 + 1;
      this.awayCantoneseName = paramCursor.getString(i16);
      int i18 = i17 + 1;
      this.homeTeamRank = paramCursor.getString(i17);
      int i19 = i18 + 1;
      this.awayTeamRank = paramCursor.getString(i18);
      int i20 = i19 + 1;
      this.homeTeamImageUrl = paramCursor.getString(i19);
      int i21 = i20 + 1;
      this.awayTeamImageUrl = paramCursor.getString(i20);
      (i21 + 1);
      this.hasLineup = paramCursor.getString(i21);
      Log.d("Match", "get match from cursor, match = " + toString());
      return;
      i15 = 0;
    }
  }

  public String getAwayCantoneseName()
  {
    return this.awayCantoneseName;
  }

  public String getAwayTeamFirstHalfScore()
  {
    return this.awayTeamFirstHalfScore;
  }

  public String getAwayTeamImageUrl()
  {
    return this.awayTeamImageUrl;
  }

  public String getAwayTeamName()
  {
    return this.awayTeamName;
  }

  public String getAwayTeamRank()
  {
    return this.awayTeamRank;
  }

  public String getAwayTeamRed()
  {
    return this.awayTeamRed;
  }

  public String getAwayTeamScore()
  {
    return this.awayTeamScore;
  }

  public String getAwayTeamYellow()
  {
    return this.awayTeamYellow;
  }

  public String getCrownChupan()
  {
    return this.crownChupan;
  }

  public String getCrownChupanString()
  {
    if (this.crownChupanString == null)
      this.crownChupanString = DataUtils.toChuPanString(this.crownChupan);
    return this.crownChupanString;
  }

  public String getDate()
  {
    return this.date;
  }

  public Date getDateOfStartDate()
  {
    if (this.dateOfStartDate == null)
      this.dateOfStartDate = StringUtil.dateFromStringByFormat(this.startDate, "yyyyMMddHHmmss");
    return this.dateOfStartDate;
  }

  public String getDateString()
  {
    String str;
    if ((this.date != null) && (this.date.length() >= 14))
      str = this.date.substring(8, 10) + ":" + this.date.substring(10, 12);
    while (true)
    {
      return str;
      str = "";
    }
  }

  public String getHasLineup()
  {
    return this.hasLineup;
  }

  public String getHomeCantoneseName()
  {
    return this.homeCantoneseName;
  }

  public String getHomeTeamFirstHalfScore()
  {
    return this.homeTeamFirstHalfScore;
  }

  public String getHomeTeamImageUrl()
  {
    return this.homeTeamImageUrl;
  }

  public String getHomeTeamName()
  {
    return this.homeTeamName;
  }

  public String getHomeTeamRank()
  {
    return this.homeTeamRank;
  }

  public String getHomeTeamRed()
  {
    return this.homeTeamRed;
  }

  public String getHomeTeamScore()
  {
    return this.homeTeamScore;
  }

  public String getHomeTeamYellow()
  {
    return this.homeTeamYellow;
  }

  public int getLeagueColor()
  {
    int j;
    if (this.leagueColor != -1)
      j = this.leagueColor;
    while (true)
    {
      return j;
      int i = Integer.parseInt(this.leagueId) % LEAGUE_COLOR.length;
      this.leagueColor = LEAGUE_COLOR[i];
      j = this.leagueColor;
    }
  }

  public String getLeagueId()
  {
    return this.leagueId;
  }

  public String getLeagueName()
  {
    return this.leagueName;
  }

  public String getMatchId()
  {
    return this.matchId;
  }

  public int getMatchScoreColor()
  {
    int i;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    case 0:
    default:
      i = -7829368;
    case -13:
    case 1:
    case 3:
    case 4:
    case -14:
    case 2:
    case -12:
    case -11:
    case -10:
    case -1:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return i;
          i = Color.argb(255, 51, 153, 0);
        }
        i = Color.argb(255, 66, 149, 223);
      }
      i = -65536;
    }
  }

  public int getMatchStatusColor()
  {
    int i;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    case 0:
    default:
      i = -7829368;
    case 1:
    case 3:
    case 4:
    case -13:
    case 2:
    case -14:
    case -12:
    case -11:
    case -10:
    case -1:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          return i;
          i = Color.argb(255, 255, 51, 0);
        }
        i = Color.argb(255, 66, 149, 223);
      }
      i = -65536;
    }
  }

  public FilterMatchStatusType getMatchStatusForFilter()
  {
    FilterMatchStatusType localFilterMatchStatusType;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    case 0:
    default:
      localFilterMatchStatusType = FilterMatchStatusType.NOT_STARTED;
    case -13:
    case 1:
    case 2:
    case 3:
    case 4:
    case -14:
    case -12:
    case -11:
    case -10:
    case -1:
    }
    while (true)
    {
      while (true)
      {
        return localFilterMatchStatusType;
        localFilterMatchStatusType = FilterMatchStatusType.ONGOING;
      }
      localFilterMatchStatusType = FilterMatchStatusType.FINISH;
    }
  }

  public String getMatchStatusOrMinutString()
  {
    String str;
    switch (this.status)
    {
    case 2:
    default:
      str = getMatchStatusString();
    case 1:
    case 3:
    }
    while (true)
    {
      return str;
      str = matchMinuteString();
    }
  }

  public String getMatchStatusString()
  {
    String str;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    default:
      str = "未开";
    case 0:
    case 1:
    case 2:
    case 3:
    case -11:
    case -12:
    case -13:
    case -14:
    case 4:
    case -1:
    case -10:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          return str;
                          str = "未开";
                        }
                        str = "上半场";
                      }
                      str = "中";
                    }
                    str = "下半场";
                  }
                  str = "待定";
                }
                str = "腰斩";
              }
              str = "中断";
            }
            str = "推迟";
          }
          str = "加";
        }
        str = "完";
      }
      str = "取消";
    }
  }

  public String getMatchTime()
  {
    return this.matchTime;
  }

  public String getStartDate()
  {
    return this.startDate;
  }

  public int getStatus()
  {
    return this.status;
  }

  public String getStatusString()
  {
    String str;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    default:
      str = "未开";
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case -11:
    case -12:
    case -13:
    case -14:
    case -1:
    case -10:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          return str;
                          str = "未开";
                        }
                        str = "上半场";
                      }
                      str = "中场";
                    }
                    str = "下半场";
                  }
                  str = "加";
                }
                str = "待定";
              }
              str = "腰斩";
            }
            str = "中断";
          }
          str = "推迟";
        }
        str = "完场";
      }
      str = "取消";
    }
  }

  public boolean hasAwayTeamRed()
  {
    return hasCard(this.awayTeamRed);
  }

  public boolean hasAwayTeamYellow()
  {
    return hasCard(this.awayTeamYellow);
  }

  public boolean hasChupan()
  {
    int i;
    if ((this.crownChupan != null) && (this.crownChupan.length() > 0))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean hasFirstHalfScore()
  {
    int i;
    if ((this.homeTeamFirstHalfScore != null) && (this.homeTeamFirstHalfScore.length() > 0) && (this.awayTeamFirstHalfScore != null) && (this.awayTeamFirstHalfScore.length() > 0))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean hasHomeTeamRed()
  {
    return hasCard(this.homeTeamRed);
  }

  public boolean hasHomeTeamYellow()
  {
    return hasCard(this.homeTeamYellow);
  }

  public int hashCode()
  {
    return (this.matchId.hashCode() + this.leagueName.hashCode() + this.homeTeamName.hashCode() + this.awayTeamName.hashCode());
  }

  public boolean isFinish()
  {
    int i;
    switch (this.status)
    {
    default:
      i = 1;
    case -13:
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean isFollow()
  {
    return this.isFollow;
  }

  public boolean isScoreJustUpdate()
  {
    int i;
    if (System.currentTimeMillis() - this.latestScoreUpdateTime <= MIN_SCORE_UPDATE_INTERVAL)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public String matchMinuteString()
  {
    String str;
    Date localDate1 = getDateOfStartDate();
    Date localDate2 = new Date();
    switch (this.status)
    {
    case 2:
    default:
      str = "";
    case 1:
    case 3:
    }
    while (true)
    {
      long l1;
      while (true)
      {
        while (true)
        {
          long l2;
          while (true)
          {
            return str;
            l2 = localDate2.getTime() / 1000L - localDate1.getTime() / 1000L + ConfigManager.getServerDifferenceTime();
            if (l2 <= 2700L)
              break;
            str = "45+";
          }
          str = String.valueOf(l2 / 60L).concat("'");
        }
        l1 = 2700L + localDate2.getTime() / 1000L - localDate1.getTime() / 1000L + ConfigManager.getServerDifferenceTime();
        if (l1 <= 5400L)
          break;
        str = "90+";
      }
      str = String.valueOf(l1 / 60L).concat("'");
    }
  }

  public boolean needDisplayScore()
  {
    int i;
    switch (this.status)
    {
    case -9:
    case -8:
    case -7:
    case -6:
    case -5:
    case -4:
    case -3:
    case -2:
    default:
      i = 0;
    case -14:
    case -12:
    case -11:
    case -10:
    case 0:
    case -13:
    case -1:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      while (true)
      {
        return i;
        i = 0;
      }
      i = 1;
    }
  }

  public void setAwayCantoneseName(String paramString)
  {
    this.awayCantoneseName = paramString;
  }

  public void setAwayTeamFirstHalfScore(String paramString)
  {
    this.awayTeamFirstHalfScore = paramString;
  }

  public void setAwayTeamImageUrl(String paramString)
  {
    this.awayTeamImageUrl = paramString;
  }

  public void setAwayTeamName(String paramString)
  {
    this.awayTeamName = paramString;
  }

  public void setAwayTeamRank(String paramString)
  {
    this.awayTeamRank = paramString;
  }

  public void setAwayTeamRed(String paramString)
  {
    this.awayTeamRed = paramString;
  }

  public void setAwayTeamScore(String paramString)
  {
    this.awayTeamScore = paramString;
  }

  public void setAwayTeamYellow(String paramString)
  {
    this.awayTeamYellow = paramString;
  }

  public void setCrownChupan(String paramString)
  {
    this.crownChupan = paramString;
  }

  public void setDate(String paramString)
  {
    this.date = paramString;
  }

  public void setHasLineup(String paramString)
  {
    this.hasLineup = paramString;
  }

  public void setHomeCantoneseName(String paramString)
  {
    this.homeCantoneseName = paramString;
  }

  public void setHomeTeamFirstHalfScore(String paramString)
  {
    this.homeTeamFirstHalfScore = paramString;
  }

  public void setHomeTeamImageUrl(String paramString)
  {
    this.homeTeamImageUrl = paramString;
  }

  public void setHomeTeamName(String paramString)
  {
    this.homeTeamName = paramString;
  }

  public void setHomeTeamRank(String paramString)
  {
    this.homeTeamRank = paramString;
  }

  public void setHomeTeamRed(String paramString)
  {
    this.homeTeamRed = paramString;
  }

  public void setHomeTeamScore(String paramString)
  {
    this.homeTeamScore = paramString;
  }

  public void setHomeTeamYellow(String paramString)
  {
    this.homeTeamYellow = paramString;
  }

  public void setIsFollow(boolean paramBoolean)
  {
    this.isFollow = paramBoolean;
  }

  public void setLeagueId(String paramString)
  {
    this.leagueId = paramString;
  }

  public void setLeagueName(String paramString)
  {
    this.leagueName = paramString;
  }

  public void setMatchId(String paramString)
  {
    this.matchId = paramString;
  }

  public void setMatchTime(String paramString)
  {
    this.matchTime = paramString;
  }

  public void setStartDate(String paramString)
  {
    this.startDate = paramString;
    this.dateOfStartDate = StringUtil.dateFromStringByFormat(paramString, "yyyyMMddHHmmss");
  }

  public void setStatus(int paramInt)
  {
    this.status = paramInt;
  }

  public void setStatus(String paramString)
  {
    this.status = safeGetInt(paramString);
  }

  public String toLongString()
  {
    return "Match [awayCantoneseName=" + this.awayCantoneseName + ", awayTeamFirstHalfScore=" + this.awayTeamFirstHalfScore + ", awayTeamImageUrl=" + this.awayTeamImageUrl + ", awayTeamName=" + this.awayTeamName + ", awayTeamRank=" + this.awayTeamRank + ", awayTeamRed=" + this.awayTeamRed + ", awayTeamScore=" + this.awayTeamScore + ", awayTeamYellow=" + this.awayTeamYellow + ", crownChupan=" + this.crownChupan + ", crownChupanString=" + this.crownChupanString + ", date=" + this.date + ", dateOfStartDate=" + this.dateOfStartDate + ", hasLineup=" + this.hasLineup + ", homeCantoneseName=" + this.homeCantoneseName + ", homeTeamFirstHalfScore=" + this.homeTeamFirstHalfScore + ", homeTeamImageUrl=" + this.homeTeamImageUrl + ", homeTeamName=" + this.homeTeamName + ", homeTeamRank=" + this.homeTeamRank + ", homeTeamRed=" + this.homeTeamRed + ", homeTeamScore=" + this.homeTeamScore + ", homeTeamYellow=" + this.homeTeamYellow + ", isFollow=" + this.isFollow + ", leagueColor=" + this.leagueColor + ", leagueId=" + this.leagueId + ", leagueName=" + this.leagueName + ", matchId=" + this.matchId + ", matchTime=" + this.matchTime + ", startDate=" + this.startDate + ", status=" + this.status + "]";
  }

  public String toString()
  {
    return "[matchId=" + this.matchId + ", home=" + this.homeTeamName + ", away=" + this.awayTeamName + "]";
  }

  public void updateDataByLiveChange(String[] paramArrayOfString)
  {
    setStatus(paramArrayOfString[1]);
    setDate(paramArrayOfString[2]);
    setStartDate(paramArrayOfString[3]);
    setHomeTeamScore(paramArrayOfString[4]);
    setAwayTeamScore(paramArrayOfString[5]);
    setHomeTeamFirstHalfScore(paramArrayOfString[6]);
    setAwayTeamFirstHalfScore(paramArrayOfString[7]);
    setHomeTeamRed(paramArrayOfString[8]);
    setAwayTeamRed(paramArrayOfString[9]);
    setHomeTeamYellow(paramArrayOfString[10]);
    setAwayTeamYellow(paramArrayOfString[11]);
  }

  public void updateMatchDetail(String[] paramArrayOfString)
  {
    if ((paramArrayOfString == null) || (paramArrayOfString.length == 0));
    while (true)
    {
      return;
      setHomeCantoneseName(paramArrayOfString[2]);
      setAwayCantoneseName(paramArrayOfString[3]);
      setMatchTime(paramArrayOfString[5]);
      setStatus(paramArrayOfString[4]);
      setHomeTeamScore(paramArrayOfString[10]);
      setAwayTeamScore(paramArrayOfString[11]);
      setHomeTeamRank(paramArrayOfString[6]);
      setAwayTeamRank(paramArrayOfString[7]);
      setHomeTeamImageUrl(paramArrayOfString[8]);
      setAwayTeamImageUrl(paramArrayOfString[9]);
    }
  }
}